# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=haskell-gtk3
pkgver=0.15.7
pkgrel=58
pkgdesc="Binding to the gtk library for Gtk2Hs."
url="https://hackage.haskell.org/package/gtk3"
license=('LGPL2.1')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'gtk3' 'haskell-pango')
makedepends=('ghc' 'haskell-gtk2hs-buildtools')
provides=('gtk2hs-gtk' 'haskell-gtk')
replaces=('gtk2hs-gtk' 'haskell-gtk')
conflicts=('gtk2hs-gtk' 'haskell-gtk')
source=("https://hackage.haskell.org/packages/archive/gtk3/${pkgver}/gtk3-${pkgver}.tar.gz")
sha512sums=('e329bec03b558948e5c346df68ad28a79d41a5abfc9acba06545f5ccea2199e58fa4086e2725ed46e51c85474ffe097e044f09f0cb307d0eb9c48cd47dcf9ccd')

build() {
    cd "${srcdir}/gtk3-${pkgver}"

    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd "${srcdir}/gtk3-${pkgver}"

    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
}
